package com.wondream.myframework.app.jade.http.response;

/**
 * 组装controller返回数据工具类
 *
 * @author penmg
 */
public class ResultUtils {

    public static ResponseResult<String> error(String msg) {
        ResponseResult<String> result = new ResponseResult<>();
        result.setFlag(false);
        result.setCode("403");
        result.setMessage(msg);

        return result;

    }

    public static ResponseResult<String> error(String errorCode, String msg) {
        ResponseResult<String> result = new ResponseResult<>();
        result.setFlag(false);
        result.setCode(errorCode);
        result.setMessage(msg);

        return result;

    }

    public static <T> ResponseResult<T> error(String errorCode, String msg, T obj) {
        ResponseResult<T> result = new ResponseResult<T>();
        result.setFlag(false);
        result.setCode(errorCode);
        result.setMessage(msg);
        result.setResult(obj);

        return result;

    }

    public static ResponseResult<String> errorLog(String errorCode, String msg, String refId) {
        ResponseResult<String> result = new ResponseResult<>();
        result.setFlag(false);
        result.setCode(errorCode);
        result.setMessage(msg);
        result.setResult(refId);

        return result;

    }

    public static <T> ResponseResult<T> success(T obj) {
        ResponseResult<T> result = new ResponseResult<T>();
        result.success(obj);
        return result;

    }

    public static ResponseResult<String> successMsg(String message) {
        ResponseResult<String> result = new ResponseResult<>();
        result.success(null);
        result.setMessage(message);
        return result;

    }

}
